package real.unknown.array;
import java.util.*;

public class ReverseInteger {
    public int reverse (int num) {
        List<Integer> list = new ArrayList<Integer>();
        int r;
        while (num != 0) {
            r = num % 10;
            num /= 10;
            list.add(r);
        }
        double sum = 0;
        int size = list.size();
        for (int i = list.size() - 1; i >= 0; i--) {
            sum += myPow(10, i) * list.get(size - i - 1);
        }
        return (int) sum;
    }

    public int myPow (int x, int n) {
        int res = 1, temp = x;
        while (n != 0) {
            if ((n & 1) != 0) {
                res *= temp;
            }
            temp *= temp;
            n >>>= 1;
        }
        return res;
    }


    public static void main(String[] args) {
        ReverseInteger r = new ReverseInteger();
        int re = r.reverse(1999);
        System.out.println(re);
        System.out.println(r.myPow(2, 10));
    }
}
